package org.zn.etl.config;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Component;
import org.zn.etl.datasource.entity.DataSourceInfo;

@Component
public class DevDataSourceInfo {
	
	private Map<String, DataSourceInfo> dataSourceInfoMap;
	
	public DataSourceInfo getDataSourceInfo(String key) {
		return dataSourceInfoMap.get(key);
	}
	
	@PostConstruct
	public void prepareDataSourceInfo(){
		
		dataSourceInfoMap=new HashMap<String, DataSourceInfo>();
		
		DataSourceInfo source=new DataSourceInfo();
		source.setUrl("jdbc:oracle:thin:@172.16.4.217:1521:rsdb");
		source.setDbType("oracle");//oracle.jdbc.OracleDriver
		source.setUsername("rs_new");
		source.setPassword("abcd_1234");
		source.setFactoryType("jdbc");
		source.setKeyName("orcl1");
		
		DataSourceInfo target=new DataSourceInfo();
		target.setUrl("jdbc:postgresql://172.16.204.121:5432/rsdb_user");//user  //reg
		target.setDbType("postgresql");
		//rsdb_reg/abcd_1234
		target.setUsername("postgres");
		target.setPassword("abcd_1234");
		target.setFactoryType("jdbc");
		target.setKeyName("rsdb_user");
	
		DataSourceInfo targetReg=new DataSourceInfo();
		targetReg.setUrl("jdbc:postgresql://172.16.204.121:5432/rsdb_reg");//user  //reg
		targetReg.setDbType("postgresql");
		//rsdb_reg/abcd_1234
		targetReg.setUsername("rsdb_reg");
		targetReg.setPassword("abcd_1234");
		targetReg.setFactoryType("spring");
		targetReg.setKeyName("shardingSphereDataSource");

		dataSourceInfoMap.put(source.getKeyName(), source);
		dataSourceInfoMap.put(target.getKeyName(), target);
		dataSourceInfoMap.put(targetReg.getKeyName(), targetReg);
		
		
	}

}
